package org.dtrd.modules.questionnaire.entity.bean;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveAnamnesis;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveOverview;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchivePhysical;
import org.dtrd.modules.patient.entity.po.DtrdEntRdPatient;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author qr
 * @date 2022/2/28 14:43
 */
@ApiModel("基本信息")
@Getter
@Setter
public class PatientBasicInfo {

    @NotBlank
    @ApiModelProperty(value = "姓名", required = true)
    private String name;

    @NotBlank
    @Length(min = 7, max = 14)
    @ApiModelProperty(value = "手机号", required = true)
    private String phone;

    @ApiModelProperty(value = "患者id", required = true)
    private Integer patientId;

    @NotNull
    @ApiModelProperty(value = "生日", required = true)
    @JsonFormat(pattern = Constant.TIME_PATTERN_SDF, timezone = "GMT+8")
    private Date birthday;

    @NotNull
    @Range(min = 1, max = 2)
    @ApiModelProperty(value = "性别, 1-男, 2-女", required = true)
    private Integer sex;

    @NotNull
    @Range(min = 1, max = 2)
    @ApiModelProperty(value = "糖尿病确诊情况, 1-未确诊, 2-已确诊", required = true)
    private Integer diabetesDiagnosis;

    @ApiModelProperty(value = "糖尿病类型：1-1型糖尿病,2-2型糖尿病,3-妊娠糖尿病,4-其他类型糖尿病", required = true)
    private Integer diabetesType;

    @ApiModelProperty(value = "体重")
    private Float weight;

    @ApiModelProperty(value = "身高")
    private Float height;

    @ApiModelProperty("血压收缩压")
    private Float bloodSystolicPress;

    @ApiModelProperty("血压舒张压")
    private Float bloodDiastolicPress;

    @ApiModelProperty("通风")
    private Integer gout;

    @ApiModelProperty("通风发生情况")
    private Integer goutStatus;

    @ApiModelProperty("血尿酸")
    private Float goutBua;

    @ApiModelProperty("疾病类型；1234 糖尿病 高血压 肥胖 痛风")
    private String diseaseProfile;

    @ApiModelProperty(value = "糖尿病确诊日期", required = true)
    @JsonFormat(pattern = Constant.TIME_PATTERN_SDF, timezone = "GMT+8")
    private Date diabetesDiagnosisDate;

    @ApiModelProperty(value = "患者体型照片")
    private String patientBodyImage;

    public PatientBasicInfo parseFromPO(DtrdEntRdPatient patient) {
        name = patient.getPatientsName();
        phone = patient.getPatientsMobile();
        patientId = patient.getDataId();
        birthday = patient.getPatientsBirthday();
        sex = patient.getPatientsSex();
        if(patient.getPatientsHeight() != null){
            height = new Float(patient.getPatientsHeight());
        }
        weight = patient.getPatientsWeight();
        return this;
    }

    public PatientBasicInfo parseFromPO(DtrdEntRdArchiveOverview overview) {
        diabetesDiagnosis = overview.getIfDiabetes();
        diabetesType = overview.getDiabetesType();
        diabetesDiagnosisDate = overview.getDiabetesDiagnoseDate();
        return this;
    }

    public PatientBasicInfo parseFromPO(DtrdEntRdArchivePhysical physical){
        height = physical.getHeight();
        weight = physical.getWeight();
        bloodDiastolicPress = physical.getBloodDiastolicPress();
        bloodSystolicPress = physical.getBloodSystolicPress();
        return this;
    }

    public PatientBasicInfo parseFromPO(DtrdEntRdArchiveAnamnesis anamnesis){
        gout = anamnesis.getGout();
        goutStatus = anamnesis.getGoutCurStatus();
        goutBua = anamnesis.getGoutBua();
        return this;
    }
}
